Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

362
Views
Electron + typescript + i18next problem - i18next::backendConnector [...] fs.readFile is not a function

I've spent almost whole day on trying to configure i18next translations in electron + typescript. I actually have no idea what can i do with it to make it work. I always get the following error: "i18next::backendConnector: loading namespace translation for language en failed TypeError: fs.readFile is not a function".

for boilderplate i've used https://github.com/diego3g/electron-typescript-react

i18n.config file (locales are in same folder and structured: locales/lang/namespace

import i18next, { InitOptions } from 'i18next'
import backend from 'i18next-fs-backend'
import { initReactI18next } from 'react-i18next'

export const DEFAULT_LANGUAGE = 'en'
export const DEFAULT_NAMESPACE = 'common'

const i18nOptions: InitOptions = {
  lng: DEFAULT_LANGUAGE,
  fallbackLng: DEFAULT_LANGUAGE,
  defaultNS: DEFAULT_NAMESPACE,
  fallbackNS: DEFAULT_NAMESPACE,
  interpolation: {
    escapeValue: false,
  },
  debug: true,
  backend: {
    loadPath: './locales/{{lng}}/{{ns}}.json',
    addPath: './locales/{{lng}}/{{ns}}.missing.json',
  },
}

i18next.use(backend).use(initReactI18next).init(i18nOptions)

export default i18next

webpack config:

const path = require('path')
var i18nextPlugin = require('ya-i18next-webpack-plugin').default

module.exports = {
  resolve: {
    extensions: ['.ts', '.tsx', '.js'],
    modules: [path.resolve(__dirname, '../src'), 'node_modules'],
    fallback: {
      fs: false,
    },
  },
  module: {
    rules: require('./rules.webpack'),
  },
  plugins: [
    new i18nextPlugin({
      defaultLanguage: 'en',
      defaultNamespace: 'common',
      languages: ['en', 'pl'],
      functionName: '_t',
      resourcePath: '..public/locales/{{lng}}/{{ns}}.json',
    }),
  ],
}

i18n initialization:

import ReactDOM from 'react-dom'
import App from './app'
import { i18n } from './config'

i18n.init()

ReactDOM.render(<App />, document.getElementById('root'))
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In electron you need to use IPC (inter-process-communication) to request a file be read or written from the electron's main process. So there is no direct fs (filesystem) access.

Try this i18next backend plugin instead: https://github.com/reZach/i18next-electron-fs-backend

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!